
package kaizone.haining.chaobohui.json;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

public class TushuoCategoryDO extends JSONResponse {

    private List<TushuoItem> data;

    public List<TushuoItem> getData() {
        return data;
    }

    public void setData(List<TushuoItem> data) {
        this.data = data;
    }

    public static TushuoCategoryDO parseJson(String str) {
        TushuoCategoryDO tushuoCategoryDO = new TushuoCategoryDO();
        try {
            JSONObject jsonObject = new JSONObject(str);
            JSONResponse response = JSONResponse.parse(jsonObject);
            tushuoCategoryDO.setJSONResponse(response);

            JSONArray jsonarray = jsonObject.optJSONArray(Data.DATA);
            if (jsonarray != null) {
                ArrayList<TushuoItem> items = new ArrayList<TushuoItem>();
                int len = jsonarray.length();
                for (int i = 0; i < len; i++) {
                    JSONObject jsonitem = jsonarray.optJSONObject(i);
                    TushuoItem item = TushuoItem.parse(jsonitem);
                    items.add(item);
                }
                tushuoCategoryDO.setData(items);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tushuoCategoryDO;
    }

}
